package com.example.blog.controller;


import com.example.blog.service.TagService;
import com.example.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/tags")
public class TagsController {

    @Autowired
    private TagService tagService;

    @GetMapping("/{categoryId}")
    public Result findTagsByCategoryID(@PathVariable("categoryId") Long categoryId){
        return tagService.findTagsByCategoryID(categoryId);
    }
    @GetMapping("detail/{tid}")
    public Result findTagDetailById(@PathVariable("tid") Long tid){
        return tagService.findTagDetailById(tid);

    }

    @GetMapping
    public Result findAll(){
        return tagService.findAll();
    }

    @GetMapping("hot")
    public Result hot(){
        int limit = 6;
        return tagService.host(limit);
    }

    @GetMapping("new")
    public Result newTags(){
        return tagService.findTagsNew();
    }
}
